/*
2018年6月14日
hdoj 1009
Problem Description
FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.
The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. 
FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of 
cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.
 

Input
The input consists of multiple test cases. Each test case begins with a line containing two non-negative integers M and N. 
Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. 
All integers are not greater than 1000.
 

Output
For each test case, print in a single line a real number accurate up to 3 decimal places, 
which is the maximum amount of JavaBeans that FatMouse can obtain.
 

Sample Input
5 3
7 2
4 3
5 2
20 3
25 18
24 15
15 10
-1 -1
 

Sample Output
13.333
31.500
思路：取两个数，然后各个仓库存的就是JavaBean 对应的需要的猫粮就是贿赂看守的猫的。总的来说就是一个贪心问题。定义一个划算比，以求最大化的喜好食物。
根据划算比进行排序，按顺序取相对应的物资即可。
*/
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
typedef struct Node 
{
	double f;
	double j;
}node;
node N[1005];
//查资料找到的cmp的定义。快排的定义
//构建划算比：F[i]/J[i] ，判断那个大
int cmp(const void *a,const void *b){
	node * A = (node *)a;
	node * B = (node *)b;
	if(A->f*B->j-B->f*A->j>0)
		return 1;
	else
		return -1;

}
int main(){
	int  m,n;
	while(scanf("%d%d",&m,&n)!=EOF &&(m!=-1 && n!=-1)){
		double maxSum = 0.0;
		for(int i = 0;i<n;i++){
			cin>>N[i].j>>N[i].f;
		}
		qsort(N,n,sizeof(N[0]),cmp);
		for(int i = 0;i<n;i++){
			if(m>0){
				if(m > N[i].f){
					maxSum += N[i].j;
					m -= N[i].f;
				}else{
					maxSum += m*N[i].j/N[i].f;
					m = 0;
				}
			}else{
				break;
			}
		}
		printf("%.3lf\n", maxSum);
	}
	return 0;
}